package result

type Codes struct {
	Message               map[uint]string
	Success               uint
	Failed                uint
	SysMenuIsExist        uint
	DelSysMenuFailed      uint
	NorDeleteMenu         uint
	RoleAlreadyExists     uint
	DelSysRoleFailed      uint
	MisssParameter        uint
	UsernameAlreadyExists uint
	StatusDisabled        uint
	SysAdminIsNotExists   uint
	PasswordNotTrue       uint
}

var ApiCode = &Codes{
	Success:               200,
	Failed:                501,
	SysMenuIsExist:        600,
	DelSysMenuFailed:      601,
	NorDeleteMenu:         602,
	RoleAlreadyExists:     603,
	DelSysRoleFailed:      604,
	MisssParameter:        605,
	UsernameAlreadyExists: 606,
	StatusDisabled:        607,
	SysAdminIsNotExists:   608,
	PasswordNotTrue:       609,
}

func init() {
	ApiCode.Message = map[uint]string{
		ApiCode.Success:               "成功",
		ApiCode.Failed:                "失败",
		ApiCode.SysMenuIsExist:        "菜单名称已存在，请重新输入！",
		ApiCode.DelSysMenuFailed:      "菜单已分配不能删除",
		ApiCode.NorDeleteMenu:         "存在子菜单不能删",
		ApiCode.RoleAlreadyExists:     "角色名称或角色key已存在，请重新输入！",
		ApiCode.DelSysRoleFailed:      "角色已分配不能删除",
		ApiCode.MisssParameter:        "缺少必填参数",
		ApiCode.UsernameAlreadyExists: "用户名已存在，请重新输入！",
		ApiCode.StatusDisabled:        "您的账号已被禁用，请联系管理员！",
		ApiCode.SysAdminIsNotExists:   "用户不存在",
		ApiCode.PasswordNotTrue:       "密码不正确",
	}
}

func (c *Codes) GetMessage(code uint) string {
	message, ok := c.Message[code]
	if !ok {
		return ""
	}
	return message
}
